Skip to content

fix(font): 补全泛族 :700 别名与平台族谱成对加载——修复 system-ui 粗体标题细体与 DejaVu w400 误粗体 - #139

Open
leizongmin wants to merge 9 commits into
mainfrom
site-opt/20261008-github
Open

leizongmin wants to merge 9 commits into
mainfrom
site-opt/20261008-github

Conversation

@leizongmin

@leizongmin leizongmin commented Oct 11, 2026 •

Copy link
Copy Markdown
Owner

解决了什么

ZeroWeb 里 font-weight:700 的 system-ui 文本渲染成细体(GitHub 顶部标题类元素同症状),而 "DejaVu Sans" 常规字重(w400)反而渲染成粗体。根因有两处(问题卡 P9-D2,R5072):

  1. 字体解析器只为 sans-serif/serif 注册了 :700 粗体别名;system-ui/cursive/fantasy 缺键,w700 查找直接落到 regular 面。monospace 族只有单 face,按 CSS Fonts 4 §5.2 的族内语义回退到族内唯一面。
  2. 平台字体按"角色"加载不成对:bold 角色只载 DejaVuSans-Bold.ttf,导致 "DejaVu Sans" 族单 face、任意字重都命中粗体;primary 角色只载 NotoSans-Regular.ttf,GitHub 栈里先于 sans-serif 出现的 "Noto Sans" 命中后 w700 停在栈中途。

修复:解析器补三族 :700 别名(与 sans-serif:700 同值)和 monospace:700 族内回退;平台加载补同族 Regular/Bold 成对清单(Linux,macOS/Windows 留 FIXME 待各平台族谱核对),并按路径去重防止极简环境族谱重复 face(首轮审查 DF-1 返修,c7a3c128c)。

附带修复:execute_script 回调排水 livelock(P9-11,254e51e35)

全量测试中 webview SW 套件在 leg 上下文必现挂死(make test 900s 墙钟掐树;main 上已有 3 次同型 flake:e55038a2a、763cfd996、bf4b25787)。真机 /proc 取证:测试线程在单次 execute_script 内 R 态 100% 单核空转。根因——drain_next_async_callback_if_pending 仅在回调通道空档(try_recv 返回 Empty)检查 20ms 预算,而 service worker 轮询链(pollRegistration / pollClientMessages)以 setTimeout(fn,0) 自续、每跳含宿主调用(解析耗时大于定时器线程 spawn);多链并行时供给压倒排水、通道永无空档,排水循环永不返回,serial 锁被占,整个测试二进制挂死。

修复:排水循环每轮迭代先查 deadline,超预算即返回(等待语义不变,recv_timeout 仍受剩余预算约束,setInterval 提前返回保留)。确定性探针:修复前 4 条慢链下单次 execute_script 卡 101.585s(exit 101),修复后 1.32s 通过;新增回归测试 execute_script_returns_with_eternal_zero_timeout_chain 以同形态锁死该机制。

怎么验证

  • 最小复现探针(本地 fixture probe2,真机 zero-browser):修复前 B1 system-ui w700 细体 → 修复后粗体;A3 "DejaVu Sans" w400 误粗体 → 修复后 regular;B4 monospace w700 保持 regular(族内单 face 回退,正确)。Chrome 同探针双端一致。
  • 新增常驻内联 reftest css-fonts/system-ui-bold-zw-001(system-ui w700 ≍ sans-serif w700;本地孪生文件入 tests/wpt-runner/local-reftests/css/css-fonts/,make import-wpt 已登记账本与 manifest)。
  • make reftest 709/709 全过(Layout 506/506、Text 203/203)——Noto Sans Bold / DejaVu Sans Regular 进入族谱后无任何既有用例像素回归。
  • 最终头 make test 全量 20567 passed / 0 failed、60s 慢测试警告 0 条(含新增字重单测与排水回归测试);make test 内 11 腿 cargo clippy --workspace --all-targets -- -D warnings(默认 v8 feature)全 Finished;cargo fmt --all -- --check 干净。
  • livelock 修复验证:修复前该腿必挂的 navigator_update_rejects_non_javascript_main_script_as_security_error 等测试在最终头通过;solo webview lib 套件 749/749(修复时点 23.82s,历次 main 同步头复跑 24.80s–26.48s);4 慢链探针 101.585s→1.32s(历次同步头复跑 1.32–1.33s)。
  • main 同步与回归修复(三次):第一次合入 origin/main(merge 3d96fd6,base 30e0e7c→247ad103e),暴露 main tip 自带两处回归——async_load 渲染会话创建被删(webview lib 26 失败)、image_cache 测试拼接(编译失败),由 9184053 修复;第二次合入 origin/main(merge 0a4d9de,base 247ad10→46b659062,带入 R5080 与 cookies M1/M2),冲突仅 imported-tests.txt 双保留,变更集 diff 等价(247ad103e..9184053 ≡ 46b6590..0a4d9de,各 571 行,产品代码零差异);第三次合入 origin/main(merge 94beafe,base 46b6590→cb4e15955)时 main 侧已独立修复同两处回归(cb4e15955、9ac80aedb),冲突按 main 侧解决、本分支修复被完全吸收,净变更集缩至 9 文件(字体族谱 + 排水修复 + reftest 账本);第四次合入 origin/main(merge c6c96dd,base cb4e159→5908c189,带入 R5081 伪元素 white-space 修复与 cookies M3 收口),冲突仅 imported-tests.txt 双保留(main R5081 2 条 + 本分支 css-fonts 1 条);历次合并头全量门禁重跑均未见回归,上列最终门禁在合并头 c6c96dd 重跑通过。

还有什么问题

  • github.com 首页大标题仍是细体:真机诊断锁定另一条根因链,已另立问题卡——P9-8 @font-face webfont 未应用(Mona Sans 加载缺失,CSSFontFaceRule 在 JS 中未定义、document.fonts 为空);P9-9 GitHub 真实样式表形状下 computed font-family 返回空串(简单 fixture 下 var()/font 简写均正常);P9-10 @font-face 页面 paint 停帧(DOM 已更新但屏幕停留在旧帧)。本修复不改这三项,首页标题字重由它们主导。
  • D1(文本空格塌陷)已独立定位到 layout 侧 hmtx 消费层,未在本切片处理。
  • macOS/Windows 的族谱成对加载留 FIXME(本切片仅覆盖 Linux 证据环境)。
  • 字重类名校验(如 :7000)留平台 FIXME 挂账(首轮审查 DF-2,minor,非阻断)。

优化前后截图

场景 1 / 问题 ID:P9-D2 最小复现探针(本地 fixture,非真实网站)——probe2 页各字族/字重组合渲染

优化前:ZeroWeb 优化后:ZeroWeb
前图:B1 行"sys w700 bold"呈细体(w700 落到 regular 面),A3 行"[DejaVu Sans] word one"呈粗体(w400 误命中 Bold 单 face)。 后图:同页同条件 B1 变粗体、A3 回归 regular;B4 mono w700 保持细体(族内回退,为预期正确行为)。
优化前:probe2 字重探针 优化后:probe2 字重探针
  • 前图 / 后图版本:parent best 4aa0fc428(修复前构建)/ 本 PR head c6c96ddac(合并头构建重拍,与 r1 附件字节级一致——连续第五次:sha256 f5ed8be6…)
  • 捕获条件:本地 HTTP fixture probe2 页、zero-browser 生产构建、viewport 800×600、DPR 1、缩放 100%、系统字体路径(Noto Sans / DejaVu / Liberation)
  • 观察到的变化及剩余差异:B1 细体→粗体、A3 误粗体→regular;探针其余行(A1/A2/A4/B2/B3/B5)修复前后均正确,无回归
  • Chrome 参考:Chrome 141 同探针双端一致(对照证据 p9p2-chrome.png / p9d2-chrome.png 保留在本地运行目录,不上传)
  • 脱敏范围:fixture 静态文本无敏感内容 / 附件内容核验:下载件与上传源字节一致、双端渲染核验通过 / PR 图片呈现核验:回读通过

场景 2 / 问题 ID:github.com 首页真实站点(登录前首页 hero 区域)

优化前:ZeroWeb 优化后:ZeroWeb
前图:github.com 首页 hero 大标题呈细体,页面整体布局正常、无 JS 报错阻断。 后图:同检查点标题仍呈细体——真实站点标题字重由 P9-8(webfont 未应用)主导,D2 的泛族修复被其掩蔽;剩余差异已按上节登记。
优化前:github.com 首页 优化后:github.com 首页
  • 前图 / 后图版本:parent best 4aa0fc428(修复前构建)/ 本 PR head c6c96ddac(合并头重拍,与现附件字节级一致——连续第五次:sha256 cccd94be…;标题仍细体)

  • 捕获条件:https://github.com/ 登录前首页、同 viewport 800×600、DPR 1、zero-browser 生产构建(前图 4aa0fc4 构建 2026-10-11、后图 c6c96dd 构建 2026-10-12)

  • 观察到的变化及剩余差异:标题字重无可见变化(预期,原因见上);首页剩余视觉问题为 P9-8/9/10,已另行登记待后续切片

  • 脱敏范围:登录前公开页面无敏感内容 / 附件内容核验:下载件渲染核验通过 / PR 图片呈现核验:回读通过

  • 已验证 best / PR head:parent best 4aa0fc428 / 本 PR head c6c96ddac

  • 实验停止原因 / 截图交付状态:运行中(未停止)/ 附件均已上传并回读核验

独立审查

环节 报告状态 head / base 证据
测试有效性首轮 PASS(历史报告) 18f99a1 / 30e0e7c 本地证据 SHA-256:22574c62b43d72a7a32a85e33343fd65c6a1168fac706277b7e2d4198fbb3007
缺陷首轮 PASS(历史报告) 18f99a1 / 30e0e7c 本地证据 SHA-256:d2149d746e663798d1df9f91a27e7971a11cc71a381606e1953248c37473c562
测试有效性复核 PASS c6c96dd / 5908c18 本地证据 SHA-256:01f90152161eb4b23f8fa5f8ce7cc122950ee4cacd9f5e3c297587e6f0499779
汇总 PASS c6c96dd / 5908c18 本地证据 SHA-256:bafce28e5f88970d822346a88ef0865833f8454157a120126f7459010822266a

未解决阻断项:0。
报告保留在本地运行目录;以上为报告记录,独立性与交付就绪另由门禁核验。

P9-D2(R5061):build_font_resolver 仅为 sans-serif/serif 注册 :700 别名,
system-ui/cursive/fantasy 缺 :700 键时 resolve_font_face 的 [":700",""] 查找
直接落 regular face(probe2 B1:system-ui w700 渲染细体);monospace:700 按
CSS Fonts 4 §5.2 族内语义回退族内唯一 face,不套用 sans 链跨族兜底。平台
角色加载补成对:bold 角色此前只载 DejaVuSans-Bold,"DejaVu Sans" 族单 face,
w400 亦命中粗体(probe2 A3);primary 角色只载 NotoSans-Regular,GitHub 栈
含 "Noto Sans"(先于 sans-serif)时 w700 停在栈中途——分别补同族
Regular/Bold companion(Linux 清单;macOS/Windows 族谱成对加载留 FIXME)。

测试资产:新增内联 reftest css-fonts/system-ui-bold-zw-001(system-ui w700
≍ sans-serif w700;本地孪生 tests/wpt-runner/local-reftests/css/css-fonts/,
make import-wpt 登记账本与 manifest);loader/system 各增 p9d2 断言。

验证:probe2 真机对照 B1 细体→粗体、A3 误粗体→regular、B4 mono w700 族内
回退保持 regular,Chrome 双端一致;make reftest 709/709(新案通过、无像素
回归);make test 20495/0;cargo clippy --workspace --all-targets
-D warnings(默认 v8)绿;cargo fmt --check 干净。

Co-Authored-By: Claude Code <noreply@anthropic.com>
@leizongmin
leizongmin force-pushed the site-opt/20261008-github branch from 8a5bada to 352032b Compare October 11, 2026 17:15
leizongmin and others added 3 commits October 12, 2026 01:16
# Conflicts:
#	tests/wpt-runner/imported-tests.txt
双审查缺陷角色 DF-1(major 非阻断):仅装 fonts-dejavu-core 的环境 primary 与
bold-regular 命中同一 DejaVuSans.ttf,load_first 无去重致 family_map=
[Reg,RegDup,Bold]、自动注册 {family}:700=ids.get(1)=RegDup——w700 渲染细体,
对 base(该环境 [Reg,Bold] 正确)回归。修复:load_first 与 generic 族循环共享
loaded_paths 集合按路径去重,同路径只载一次;新增 DF-1 去重单测。

另更正 DF-3 注释矛盾:monospace:700 的 :700 语义跟随解析结果族(mono 命中
专属族取族内 Bold/自身;generic 全落空时取 default 族谱系),此前「禁跨族」
表述与 default 臂实际行为不符——禁的是 R3993「任意族第二 face」兜底。

验证:cargo test -p zero-render-foundation --lib font 168/0(含 DF-1 测试);
fmt 干净;clippy workspace -D warnings 绿(默认 v8)。DF-2(清单错位无运行时
校验)挂账与平台族谱 FIXME 一并处理。

Co-Authored-By: Claude Code <noreply@anthropic.com>
drain_next_async_callback_if_pending 原先仅在 try_recv 空档检查 20ms 预算;
被排水的回调以 setTimeout(fn, 0) 自续时(service worker 轮询链每跳含宿主
调用,解析耗时大于定时器线程 spawn),多链并行供给使通道永无空档,Ok 分支
无限消耗——make test 全量并行下测试线程在单次 execute_script 内 100% 单核
空转(实测 101.6s 不返回),serial 锁被占、后续测试全部泊住,二进制挂到
test-guard 900s 墙钟(leg 上下文 3/3 复现)。

排水循环顶部补每轮 deadline 检查:等待语义不变(recv_timeout 仍受剩余预算
约束),仅将消耗总量限制在预算内,恢复 execute_script 同步调用必须返回的
契约。新增 async_drain_bound 回归测试(4 条慢跳永续链):修复前 call 0 耗时
101.6s 断言失败,修复后全套 1.32s 通过;workspace make test 20531P/0F、
60s 警告 0,reftest 709/709。

Co-Authored-By: Claude Code <noreply@anthropic.com>
@leizongmin
leizongmin marked this pull request as ready for review October 12, 2026 02:02
@cursor

cursor Bot commented Oct 12, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: c4e55650-ce23-4d11-a01e-e0848a86f3cf)

…hub(imported-tests.txt 双保留)

同步 main(#140–#144:R5073–R5079 layout/css 修复、webmessaging M2/M3、CORS range
safelist、shape_fallback 中文字体 fallback chain)。冲突仅 tests/wpt-runner/
imported-tests.txt:双方新增条目均保留(main 4 条 + 本分支
css-fonts/system-ui-bold-zw-001 1 条),无产品代码手工改动。

Co-Authored-By: Claude Code <noreply@anthropic.com>
@cursor

cursor Bot commented Oct 12, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: 35ccbba5-94cc-4b4c-a1fd-13766fe7920f)

…创建、还原 image_cache 测试拼接

归因(均存在于 main tip 247ad10,非本分支改动引入;merge-tree 单侧变更不产生
冲突,故障内容随 main 带入):

1. async_load.rs:580 `expect("session")` panic——zero-webview lib 26 个测试失败
   (async_load 家族 + redirect_tv1)及 zero-webdriver http_session 8 个 500,
   同一根因:e776d6875/0620e8103「移除 T5DIAG 临时诊断」把生产行
   `self.render_session = Some(BudgetedRenderSession::new(html, css_for_render))`
   一并删除(30e0e7c0d 与 e776d68^ 均在场;main tip 上 BudgetedRenderSession::new
   仅剩 webview.rs 测试内的直接构造)。恢复该行,使 0620e81 自述保留的
   substitute_css_vars_text 生产路径重新接线(css_for_render 不再是死局部变量)。

2. image_cache.rs 测试块拼接损伤——zero-render-foundation lib test 编译失败
   (duplicated attribute / dead_code / needless_borrow 三错):3ed4223cf 插入
   decode_data_uri_svg_background 时替换了原测试的 fn 头,致原
   decode_image_bytes_dispatches_by_magic 失去 #[test] 且被改名
   test_decode_image_bytes_dispatches_by_magic,新测试带双 #[test]。按其本意还原:
   原测试恢复原名与属性,SVG 测试独立置于其后(&src→src)。

两处在 main 上均未被 pr-precheck 覆盖(workspace check 不含 lib test 目标与
集成测试执行)。本提交使合并头恢复可测基线,供全量门禁与 PR #139 交付。

Co-Authored-By: Claude Code <noreply@anthropic.com>
@cursor

cursor Bot commented Oct 12, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: 1615c4bf-1a4f-4953-9761-b86d9b7fe65f)

…hub(imported-tests.txt 双保留)

同步 main(46b659062:#145–#147 cookies-compat M1/M2 document.cookie 语义重写、
R5080 colgroup/column min-max-height 修复)。冲突仅 tests/wpt-runner/imported-tests.txt:
双方新增条目均保留(main R5080 4 条 + 本分支 css-fonts/system-ui-bold-zw-001 1 条),
无产品代码手工改动。

Co-Authored-By: Claude Code <noreply@anthropic.com>
@cursor

cursor Bot commented Oct 12, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: 5209bde2-e280-4ccb-aac2-c7e9a0533d93)

…hub(main 规范修复替代本分支同型回归修复)

main 侧 cb4e159(render_session 初始化恢复)与 9ac80ae(image_cache 测试拼接
修复)独立修复了本分支 9184053 已修复的同两处回归;冲突按 main 侧解决,
本分支净变更集缩为 9 文件(字体族谱 + 排水修复 + reftest 账本)。

Co-Authored-By: Claude Code <noreply@anthropic.com>
@cursor

cursor Bot commented Oct 12, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: e4248b2c-26b9-4e1b-89a2-0c227d25a329)

@leizongmin leizongmin closed this Oct 12, 2026
@leizongmin leizongmin reopened this Oct 12, 2026
@cursor

cursor Bot commented Oct 12, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: ba85b034-66ce-418e-99ae-17404292a4c9)

…hub(imported-tests.txt 双保留)

main 侧带入 cookies M3 收口与 R5081 伪元素 white-space 修复;冲突仅
imported-tests.txt,main 2 条 R5081 条目与本分支 css-fonts 条目双保留。

Co-Authored-By: Claude Code <noreply@anthropic.com>
@cursor

cursor Bot commented Oct 12, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: e2e4c00c-5a93-44f3-80cd-94e6caa71e53)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant